<%= form_for [refinery, :portfolio_admin, @gallery, @item] do |f| -%>
  <%= render :partial => "/refinery/admin/error_messages", :locals => {
             :object => @item,
             :include_object_name => true } %>

  <%= render :partial => "refinery/portfolio/admin/shared/locale_picker",
             :locals => {
               :current_locale => Thread.current[:globalize_locale]
             } if defined?(::Refinery::I18n) %>

  <div class='field'>
    <%= f.label :title -%>
    <%= f.text_field :title, :class => 'larger widest' -%>
  </div>

  <%= render :partial => '/refinery/admin/image_picker',
              :locals => {
                :f => f,
                :field => :image_id,
                :image => @item.image,
                :toggle_image_display => false
              } %>

  <% if params[:gallery_id].present? %>
    <%= hidden_field :item, :gallery_id, value: params[:gallery_id] %>
  <% else %>
    <div class='field'>
      <span class='label_with_help'>
        <%= f.label :gallery_id, t('gallery', :scope => 'refinery.portfolio.admin.items.item') -%>
        <%= refinery_help_tag t('gallery_help', :scope => 'refinery.portfolio.admin.items.item') -%>
      </span>
      <%= f.select :gallery_id, nested_set_options(::Refinery::Portfolio::Gallery, @gallery) { |i| "#{'-' * i.level} #{i.title}" }, :include_blank => true %>
    </div>
  <% end %>

  <%= render :partial => "/refinery/admin/form_actions",
              :locals => {
                :f => f,
                :continue_editing => false,
                :delete_title => t('delete', :scope => 'refinery.portfolio.admin.items.item'),
                :delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @item.title)
              } %>

<% end -%>

<% content_for :javascripts do %>
  <script>
    $(document).ready(function(){
      page_options.init(false, '', '');
    });
  </script>
<% end %>
